
#include <QtWidgets>
#include "VideoPlayItemWidget.h"
#include "VideoItemTool.h"

VideoPlayItemWidget::VideoPlayItemWidget(IPCManager* mgr, int videoIndex, QWidget* parent)
	:QWidget(parent)
	, ipc_mgr(mgr)
	, video_index(videoIndex)
{
	ui.setupUi(this); 
	toolBtn = new VideoItemToolWidget(mgr , videoIndex , this);
	toolBtn->setWindowFlags(Qt::FramelessWindowHint | Qt::SubWindow);//|Qt::WindowStaysOnTopHint
	toolBtn->setAttribute(Qt::WA_TranslucentBackground, true);
	toolBtn->hide();
	connect(toolBtn, SIGNAL(captureSuccess(QString)), this, SIGNAL(captureSuccess(QString)));
	setMouseTracking(true);
}
VideoPlayItemWidget::~VideoPlayItemWidget()
{

}

void VideoPlayItemWidget::ToolBarEnable(bool enable)
{
	if (enable) {
		int margin = 2;
		QWidget*parent = qobject_cast<QWidget*>( toolBtn->parent());
		toolBtn->move(margin, parent->height() - toolBtn->height()- margin);
		toolBtn->raise();
		toolBtn->show();
	}
	else {
		toolBtn->hide();
	}
}


void VideoPlayItemWidget::mouseMoveEvent(QMouseEvent *event)
{

	//qDebug() << __FUNCTION__ << event->localPos();

}